/*
 -------------------------------------------------------------------------------
 ITG3200.h
 ITG3200 Project
 
 Class description... .
 
 CONSTRUCTORS:
    ITG3200();    
 
 PUBLIC PROPERTIES:
    prop1 - description... .
    prop2 - description... .
 
 PUBLIC METHODS:
    type method1(type arg1);
        Description... .
            arg1 - description... .
 
 NOTES:
 
 
 EXAMPLES:

 
 Initially created by Rowland O'Flaherty on 1/12/12.
 
 Version 1.0
 -------------------------------------------------------------------------------
 */

#ifndef _ITG3200_h_
#define _ITG3200_h_

//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include <Arduino.h>


class ITG3200 {
	//--------------------------------------------------------------------------
	// Friends
	//--------------------------------------------------------------------------
	
	
	//--------------------------------------------------------------------------
	// Friend Overloaded Operators
	//--------------------------------------------------------------------------
	
	
public:
	//--------------------------------------------------------------------------
	// Constants, Enums, and Types
	//--------------------------------------------------------------------------
	
	
	//--------------------------------------------------------------------------
	// Lifecycle
	//--------------------------------------------------------------------------
	
	// Constructors
	ITG3200();
	
	// Destructor
	virtual ~ITG3200();
	
	// Copy constructor
	ITG3200(const ITG3200& srcObj);
	
	// Assignment operator
	const ITG3200& operator=(const ITG3200& rhsObj);
	
	
	//--------------------------------------------------------------------------
	// Overloaded Operators
	//--------------------------------------------------------------------------
	
	
	//--------------------------------------------------------------------------
	// Public Member Functions
	//--------------------------------------------------------------------------
	void initialize();
	int gyroX();
    	int gyroY();
    	int gyroZ();
	void calibrate(int samples);
    
    	int getCalX() { return _calX;}
    	int getCalY() { return _calY;}
    	int getCalZ() { return _calZ;}
    
	//--------------------------------------------------------------------------
	// Public Member Variables
	//--------------------------------------------------------------------------
	
protected:
	//--------------------------------------------------------------------------
	// Protected Member Functions
	//--------------------------------------------------------------------------
	
	
	//--------------------------------------------------------------------------
	// Protected Member Variables
	//--------------------------------------------------------------------------
	
	
private:
	//--------------------------------------------------------------------------
	// Lifecycle
	//--------------------------------------------------------------------------
	void copyHelper(const ITG3200& srcObj);
	
	//--------------------------------------------------------------------------
	// Private Member Functions
	//--------------------------------------------------------------------------
	byte readByte(byte address);
    void writeByte(byte address, byte value);
	
	//--------------------------------------------------------------------------
	// Private Member Variables
	//--------------------------------------------------------------------------
    // Device constant
    static const byte _ITG3200Address = 0x69; // I2C address of ITG3200
    
    // Register address
	static const char _SMPLRTDIV= 0x15;
    static const char _DLPF = 0x16;
    static const char _xH = 0x1D;
	static const char _xL = 0x1E;
    static const char _yH = 0x1F;
    static const char _yL = 0x20;
    static const char _zH = 0x21;
	static const char _zL = 0x22;
    
    static const char _DLPF0 = (0<<0);
    static const char _DLPF1 = (1<<1);
    static const char _DLPF2 = (0<<2);
    static const char _FS0 = (1<<3);
    static const char _FS1 = (1<<4);

    // Calibration variables
    int _calX;
    int _calY;
    int _calZ;
	
};

#endif
